package com.example.cofeed.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.Subscription;

/**
 * Created by mqwang on 2017/9/24.
 */

public class SubscriptionAdapter extends BaseQuickAdapter<Subscription, BaseViewHolder> {
    private final int type;

    public SubscriptionAdapter(int type) {
        super(R.layout.item_subscription_list);
        this.type = type;

    }

    @Override
    protected void convert(BaseViewHolder helper, Subscription item) {

        if (type == 0){
            helper.getView(R.id.select_iv).setVisibility(View.GONE);
            helper.getView(R.id.arrow_iv).setVisibility(View.VISIBLE);
        }
        else{
            helper.getView(R.id.select_iv).setVisibility(View.VISIBLE);
            helper.getView(R.id.arrow_iv).setVisibility(View.GONE);
        }
        if (item.isSelect) {
            helper.setImageResource(R.id.select_iv, R.mipmap.seltok);
        } else {
            helper.setImageResource(R.id.select_iv, R.mipmap.seltno);
        }

        helper.setText(R.id.name_tv, item.title);
        helper.setText(R.id.desc_tv, item.citys);

    }

    public void selectItem(Subscription subscription){
        subscription.isSelect = !subscription.isSelect;
        notifyDataSetChanged();

    }

}
